#!/usr/bin/python
# -*- coding: UTF-8 -*-
from business.User.UserCompetation import UserCompetation
import pytest
import unittest

import re
import time
from datetime import datetime

import unittest
from business.login import Login
from pom.base import BaseDriver
from ddt import data, ddt, unpack, file_data
from selenium import webdriver
from common.api_corrent_answer import api_answer



@ddt
class TestUserCompetation(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        cls.dir = api_answer().api_answer("测试团队折线图")

    def setUp(self):
        self.driver = webdriver.Chrome()
        BaseDriver(self.driver).get_url()
        self.l = Login(self.driver)
        self.u = UserCompetation(self.driver)

    def tearDown(self):
        BaseDriver(self.driver).quit_webdriver()

    @file_data(r"D:\pythoncode\trainning\common\user.json")
    @unpack
    def test_answer(self, name, passwd):
        self.l.system_login(name, passwd)
        # score = api_answer().set_answer(self.__class__.dir, 44, name)
        # total_score = score[1]
        # score = score[0]
        total_score = api_answer().set_answer(self.__class__.dir, 10, name)[1]
        answer_file = self.__class__.dir+'/{}.csv'.format(name)
        #print(score, total_score)
        #print(round(int(score)/int(total_score), 4))
        # api_answer().set_answer(r'D:\pythoncode\trainning\common\anser_csv\测试大屏详细状态', 43, name)
        #
        # answer_file =  r'D:\pythoncode\trainning\common\anser_csv\1616'+ '\{}.csv'.format('j10')
        self.u.answer(answer_file, 44)
        time.sleep(5)

if __name__ == '__main__':
    unittest.main()